package cn.smile.controller.basic;

import cn.smile.bean.dto.basic.DicInfoDTO;
import cn.smile.bean.dto.basic.PickerDTO;
import cn.smile.bean.form.basic.dic.DicAddForm;
import cn.smile.business.basic.IDicInfoService;
import cn.smile.commons.response.MyResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("api/dic")
public class DicController {

    @Resource
    private IDicInfoService service;

    @PostMapping(value = "addDic")
    public MyResult<Boolean> addDic(@Valid @RequestBody DicAddForm form) {
        return MyResult.OK(service.addDic(form));
    }

    @GetMapping(value = "getDicList")
    public MyResult<List<DicInfoDTO>> getDicList(@RequestParam("parentId") String parentId) {
        return MyResult.OK(service.getDicList(parentId));
    }

    @GetMapping(value = "miniProjectDicList")
    public MyResult<List<PickerDTO>> miniProjectDicList(@RequestParam("parentId") String parentId){
        return MyResult.OK(service.miniProjectDicList(parentId));
    }
}
